﻿using System;
using System.Data;
using System.Collections.Generic;
using OnlineManagement.Common;
using OnlineManagement.Model;
using OnlineManagement.DALFactory;
using OnlineManagement.IDAL;
namespace OnlineManagement.BLL.Dal
{
	/// <summary>
	/// HybridizationRecord
	/// </summary>
	public partial class HybridizationRecord
	{
		private readonly IHybridizationRecord dal=DataAccess.CreateHybridizationRecord();
		public HybridizationRecord()
		{}

		#region  ExtensionMethod

        /// <summary>
        ///  获取空怀可配种母猪信息
        /// </summary>
        /// <param name="hoggeryId"></param>
        /// <returns></returns>
        public DataSet GetHybridizationSow(int hoggeryId) {
            try
            {
                return dal.GetHybridizationSow(hoggeryId);
            }catch(Exception ex){
                throw new Exception(Common.PubMsg.ServerError);
            }
        }


        /// <summary>
        /// 获取指定母猪信息，比如饲养员，猪圈名称，母猪品种
        /// </summary>
        /// <param name="hoggeryId"></param>
        /// <param name="sowId"></param>
        /// <returns></returns>
        public Model.SowInfoForHybrizationRecord GetHybridizationSowBasicInfo(int hoggeryId, Guid sowId)
        {
            try
            {
                return dal.GetHybridizationSowBasicInfo(hoggeryId, sowId);
            }
            catch (Exception ex) { throw new Exception(PubMsg.ServerError); }
        }

       public bool SowHybrizationAddOrUpdate(Model.HybridizationRecord record, out string returnValue) {
           try
           {
               return dal.SowHybrizationAddOrUpdate(record, out returnValue);
           }catch(Exception ex){
               throw new Exception(PubMsg.ServerError);
           }
       }
       public bool SowHybrizationAddOrUpdate
            (System.Collections.Generic.List<Model.HybridizationRecord> records,
            out string returnValue)
       {
           return dal.SowHybrizationAddOrUpdate(records, out returnValue);
       }

        /// <summary>
       ///  母猪确认怀孕，需要先进行反情检查或者妊娠检查，当检查成功调用此方法
        /// </summary>
        /// <param name="hoggeryId"></param>
        /// <param name="sowId"></param>
        /// <param name="updateDate"></param>
        /// <returns></returns>
       public bool SowPregnancyRecord(int hoggeryId, Guid sowId,int isFanQing, DateTime updateDate,out string returnValue) {
           return dal.SowPregnancyRecord(hoggeryId, sowId,isFanQing,updateDate,out returnValue);
       }
        /// <summary>
       /// 母猪流产，母猪回到空怀期，流产次数加1，原因及时间记录到日志中
        /// </summary>
        /// <param name="sowId"></param>
        /// <param name="returnValue"></param>
        /// <returns></returns>
       public bool SowAbortion(int hoggeryId,Guid sowId, out string returnValue) {
           return dal.SowAbortion(hoggeryId,sowId, out returnValue);
       }

        /// <summary>
        /// 获取指定母猪的配种信息,返回不定数目的表，每一个表包含配种全部信息
        /// </summary>
        /// <param name="hoggeryId"></param>
        /// <param name="sowId"></param>
        /// <param name="isHybridizateDone"></param>
        /// <returns></returns>
       public DataSet GetSowHybrizationRecords(int hoggeryId, Guid sowId, bool isHybridizateDone) {
           return dal.GetSowHybrizationRecords(hoggeryId, sowId, isHybridizateDone);
       }

		#endregion  ExtensionMethod
	}
}

